// pages/mine/user/user.js
var gd = getApp().globalData;
const net = require('../../../utils/net.js');
const util = require('../../../utils/util.js');
var posting = false;
var dialog = null;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    user: {
      name: wx.getStorageSync("name"),
      faceurl:"",
      mobile: wx.getStorageSync("mobile").replace(gd.mobile.substr(3,4),"****"),
      shop_name: wx.getStorageSync("shop_name"),
      face1_status: gd.face1_status
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //  wx.setStorageSync("face1_status",0)
  }, 
  gonav(e){
    var path = e.currentTarget.dataset.path;
    if (path =="../face/face"){
      if (this.data.user.face1_status==2){
        dialog.showDialog({
          msg:"已通过，无需再次采集"
        });
        return;
      }
    }
    util.Forward(path);
  },
  logout(){
   wx.removeStorageSync("id");
   wx.removeStorageSync("shop_id");
   wx.removeStorageSync("face1_status")
   wx.removeStorageSync("face1")
   util.Forward("../../index/index",3);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    dialog = this.selectComponent("#dialog");
    
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    console.log("onshow",gd);
    var user = this.data.user;
    user.shop_name = wx.getStorageSync("shop_name")
    user.mobile = wx.getStorageSync("mobile").replace(gd.mobile.substr(3, 4), "****");
    user.name = wx.getStorageSync("name"); 
    var tmp = gd.userInfo.avatarUrl;
    if (gd.face1_status != 0) tmp = gd.face1;
    user.faceurl = tmp;
    user.face1_status = wx.getStorageSync("face1_status");
    this.setData({
      user
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})